package com.mooc.lib_video.ui.detail

import com.mooc.lib_network.entity.BaseRepository
import com.mooc.lib_network.entity.NetResult
import com.mooc.lib_network.entity.RetrofitSingle
import com.mooc.lib_video.ApiService
import com.mooc.lib_video.model.CommentsEntity
import com.mooc.lib_video.model.DetailFeedCommentEntity
import com.mooc.lib_video.model.SendCommentEntity
import retrofit2.http.Field

class DetailRepo : BaseRepository() {

    suspend fun comments(id : Int,itemId:Long,
                         pageCount:Int,userId:Long):NetResult<DetailFeedCommentEntity>{
        return requestCall  (call = {requestComments(id, itemId, pageCount, userId)})
    }

    suspend fun sendComment(commentText: String,
                            height: Int,
                            image_url: String,
                            itemId: Long,
                            userId: Long,
                            video_url: String,
                            width: Int):NetResult<SendCommentEntity>{
        return requestCall (call = {requestSendComment(commentText,
                height, image_url, itemId, userId, video_url, width)})
    }

    suspend fun requestComments(id : Int,itemId:Long,
                                pageCount:Int,userId:Long)
            :NetResult<DetailFeedCommentEntity>{
        return handlerResponse(
                RetrofitSingle.instance().getRetrofit().create(ApiService::class.java)
                        .requestDetailComment(id, itemId, pageCount, userId)
        )
    }

    suspend fun requestSendComment(commentText: String,
                                   height: Int,
                                   image_url: String,
                                   itemId: Long,
                                   userId: Long,
                                   video_url: String,
                                   width: Int):NetResult<SendCommentEntity>{
        return handlerResponse(RetrofitSingle.instance().getRetrofit().create(ApiService::class.java)
                .requestSendComments(commentText, height, image_url, itemId, userId, video_url, width))
    }

}